﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  CallProviderActivity.cs
//    
// Abstract:
//
//  Workflow Activity that exposes the ICallProvider interface for
//  giving an established call to workflow.
//  
//--
using System.Diagnostics;
using System.Workflow.ComponentModel;
using Microsoft.Rtc.Collaboration;
using Microsoft.Rtc.Collaboration.AudioVideo;
using Microsoft.Rtc.Workflow.Activities;
using Microsoft.Rtc.Workflow.Common;
using Microsoft.Speech.AudioFormat;

namespace Microsoft.EnhancedReminders.Dispatcher.Workflow
{
    /// <summary>
    ///  Workflow Activity that has CallProvider property for giving an established call to workflow.    
    /// </summary>
	public partial class CallProviderActivity: Activity
	{
        private CallProvider _callProvider;

        /// <summary>
        /// ctor.
        /// </summary>
        public CallProviderActivity()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets CallProvider.
        /// </summary>
        public CallProvider CallProvider
        {
            get
            {
                return _callProvider;
            }
        }

       

        /// <summary>
        /// Override the default implementation of Execute. Dequeues the call from the
        /// CommunicationsWorkflowRuntimeService so that the UCMA workflow activities can
        /// use it in their operations.
        /// </summary>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            CommunicationsWorkflowRuntimeService runtime = executionContext.GetService<CommunicationsWorkflowRuntimeService>();
            Debug.Assert(runtime != null, "runtime != null");

            _callProvider = new CallProvider(runtime.DequeueCall(WorkflowInstanceId), runtime.GetWorkflowCulture(WorkflowInstanceId));



            return base.Execute(executionContext);
        }

       
    }
}
